package com.ktjy.service;

import net.sf.cglib.proxy.Enhancer;

import java.lang.reflect.Proxy;

public class IntermediaryJdkProxyFactory {
    private static IntermediaryMethodInterceptor callback=new IntermediaryMethodInterceptor();

    public static <T> T create(Object target){
        Enhancer enhancer=new Enhancer();
        enhancer.setCallback(callback);
        enhancer.setSuperclass((Class) target);
        return (T) enhancer.create();
//        IntermediaryInvocationHandler handler = new IntermediaryInvocationHandler();
//        handler.setTarget(target);
//        return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), handler);
    }
}
